package api

import (
	"github.com/valyala/fasthttp"
	"permission/config/error_code"
	"permission/vigo_loger"
	"permission/vigo_tool"
)

type BaseServer struct {
	// todo
}

//  返回参数
type ApiBaseResponse struct {
	HttpCode int                      `json:"http_code"`
	Status   error_code.Code_type_int `json:"status"`
	Info     string                   `json:"info"`
	Result   interface{}              `json:"result"`
}

func NewBaseServer() *BaseServer {
	return new(BaseServer)
}

func (bs *BaseServer) construct(ctx *fasthttp.RequestCtx) {
	return
	// todo
	ngx_ip := ctx.RemoteIP().String()
	remoteIp := string(ctx.Request.Header.PeekBytes([]byte("X-Real-Ip")))
	allow := vigo_tool.GdIpWhitelist(ngx_ip, remoteIp)
	if !allow {
		vigo_loger.AddGrayLog("blacklist{ip:" + ngx_ip + ", remote ip:" + remoteIp + "}")
		ctx.Redirect("/whitelist", 302)
	}
}
